#include<iostream>
double ex(double x , int n);
int main(){
        double base,result;
        int exponent;
        using namespace std;
        std::cout << "Enter the base number: ";
        std::cin >> base;

        std::cout << "Enter the exponent: ";
        std::cin >> exponent;

        result=ex(base,exponent);

        std::cout << "Result: " << result << std::endl;

        return 0;
}


double ex(double x , int n){
        double m;
        double final;
        if(n==0){
                return 1.0;
        }else if(n%2==0){
                m=ex(x,n/2);
                final=m*m;
                return final;
        }else if(n%2!=0){
                m=ex(x,(n-1)/2);
                final=m*m*x;
                return final;
        }
        return 0.0;
}


